<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('售后管理列表列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>装配单表头单号：</label>
                                <input type="text" name="mcode"/>
                            </li>
                            <li class="select-time">
                                <label>售后服务日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginDdate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endDdate]"/>
                            </li>
                            <!--<li>
                                <label>分店代码：</label>
                                <input type="text" name="shop"/>
                            </li>-->
                            <li>
                                <label>售后门店：</label>
                                <input type="text" name="shopname"/>
                            </li>
                            <li>
                                <label>安装门店：</label>
                                <input type="text" name="azshopname"/>
                            </li>
                            <li>
                                <label>VIN码：</label>
                                <input type="text" name="vin"/>
                            </li>
                            <li>
                                <label>类型：</label>
                                <select name="ctype">
                                    <option value="">所有</option>
                                    <option value="保修">保修</option>
                                    <option value="换货">换货</option>
                                </select>
                            </li>
                            <li>
                                <label>服务人员：</label>
                                <input type="text" name="sericeemp"/>
                            </li>
                            <li>
                                <label>服务内容记录：</label>
                                <input type="text" name="sericedesc"/>
                            </li>
                            <li>
                                <label>产品代码：</label>
                                <input type="text" name="pcode"/>
                            </li>
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="pname"/>
                            </li>
                            <li>
                                <label>产品规格：</label>
                                <input type="text" name="pstd"/>
                            </li>
                            <li>
                                <label>单位：</label>
                                <input type="text" name="punit"/>
                            </li>
                            <!--<li>
                                <label>数量：</label>
                                <input type="text" name="qty"/>
                            </li>-->
                            <!--<li class="select-time">
                                <label>保存时自动的系统时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginSysdt]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endSysdt]"/>
                            </li>-->
                            <li>
                                <label>打单人员：</label>
                                <input type="text" name="emp"/>
                            </li>
                            <li>
                                <label>换货处理人：</label>
                                <input type="text" name="dealemp"/>
                            </li>
                            <li class="select-time">
                                <label>换货处理时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginDealdt]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endDealdt]"/>
                            </li>
                            <li>
                                <label>备注：</label>
                                <input type="text" name="smemo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="erp:saleservices:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="erp:saleservices:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="erp:saleservices:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="erp:saleservices:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('erp:saleservices:edit')}]];
        var removeFlag = [[${@permission.hasPermi('erp:saleservices:remove')}]];
        var prefix = ctx + "erp/saleservices";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "售后管理列表",
                columns: [{
                    checkbox: true
                },
               /* {
                    field: 'mid', 
                    title: '装配单表头id'
                },*/
                {
                    field: 'code',
                    title: '装配单表头单号'
                },
                    {
                        field: 'vin',
                        title: ' VIN码'
                    },
                {
                    field: 'ddate', 
                    title: '售后服务日期'
                },
                {
                    field: 'shopname', 
                    title: '售后门店'
                },
                    {
                    field: 'azshopname',
                    title: '安装门店'
                },
                {
                    field: 'ctype', 
                    title: '类型'
                },
                {
                    field: 'sericeemp', 
                    title: '服务人员'
                },
                {
                    field: 'sericedesc', 
                    title: '服务内容记录'
                },
                {
                    field: 'pcode', 
                    title: '产品代码'
                },
                {
                    field: 'pname', 
                    title: '产品名称'
                },
                {
                    field: 'pstd', 
                    title: '产品规格'
                },
                {
                    field: 'punit', 
                    title: '单位'
                },/*
                {
                    field: 'qty', 
                    title: '数量'
                },*/
               /* {
                    field: 'sysdt', 
                    title: '保存时自动的系统时间'
                },*/
                {
                    field: 'emp', 
                    title: '打单人员'
                },
                {
                    field: 'dealemp', 
                    title: '换货处理人'
                },
                {
                    field: 'dealdt', 
                    title: '换货处理时间'
                },
                {
                    field: 'smemo', 
                    title: '备注'
                },
                    {
                        field: 'st',
                        title: '状态'
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.st == '未处理' && row.ctype == '换货'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="review(\'' + row.id + '\')"><i class="fa fa-edit"></i>处理</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');
                        }else
                        if(row.st =='已处理' && row.ctype == '换货'){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="disReview(\'' + row.id + '\')"><i class="fa fa-remove"></i>撤销处理</a>');
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');
                        }else{
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function review(id) {
            debugger;
            $.ajax({
                type: "post",
                url: ctx + "erp/saleservices/reviewSaleService?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("审批成功");
                }
            });
            $("#bootstrap-table").bootstrapTable('refresh', {
                silent: true
            });
        }

        function disReview(id) {
            debugger;
            $.ajax({
                type: "post",
                url: ctx + "erp/saleservices/disReviewSaleService?id="+id,
                success: function(r) {
                    $.modal.msgSuccess("撤销成功");
                }
            });
            $("#bootstrap-table").bootstrapTable('refresh', {
                silent: true
            });
        }

    </script>
</body>
</html>